<template>
  <div class="ruijie-header-box">
    <ul class="ruijie-header-right">
      <li>
        <el-dropdown trigger="click">
          <span class="el-dropdown-link" >
            张子光 <i class="el-icon-arrow-down el-icon--right"/>
          </span>
          <el-dropdown-menu slot="dropdown">
            <el-dropdown-item
              @click.native="showlogin"
              command="a">模态登录</el-dropdown-item>
            <el-dropdown-item
              command="b"
              @click.native="Redirect">重定向登录</el-dropdown-item>
            <el-dropdown-item command="c">螺蛳粉</el-dropdown-item>
          </el-dropdown-menu>
        </el-dropdown>
      </li>
    </ul>
  </div>
</template>
<script type="es6">
import EventBus from '../../libs/eventBus';
import config from '../../config';
export default {
  name: 'Header',
  data () {
    return {

    };
  },
  methods: {
    showlogin () {
      this.$SSO.showModal(config.system.SSOModalUrl);
    },
    Redirect () {
      this.$SSO.Redirect(config.system.SSORedirectlUrl);
    }
  },
  mounted () {
    // 接收模态登录成功后返回的 user 数据
    EventBus.$on('SSOuser', (user) => {
      console.log(user);
    });
    // 如果是重定向登录 通过window.getSSOuser()获得 checklogin 返回的user信息
    if (typeof window.getSSOuser === 'function') {
      let user = window.getSSOuser();

      console.log(user);
    }
  }
};
</script>
<style lang="less">
    @import "../../styles/common.less";
    .@{prefix}{
        &header-box{
            width: 100%;
            height: 100%;
            color: #fff;
            .el-dropdown{
                color: #fff;
                line-height: 60px;
                cursor: pointer;
            }
        }
        &header-right{
            float: right;
            li{
                display: inline-block;
                padding: 0px 20px;
            }
        }
    }
</style>
